﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Mian : MonoBehaviour
{
    public GameObject loadingpanel;
    public GameObject lobbypanel;
    public GameObject mailpanel;
    public GameObject serverpanel;
    public GameObject settingpanel;
    public GameObject shoppanel;
    public GameObject gamepanel;

    public AudioSource m_clipBgm;
    public AudioSource m_clipClick;
    public void Start()
    {
        OnInitListen();
        AudioManager.Instance.OnSetAudioPrefab(m_clipBgm, m_clipClick);
        AudioManager.Instance.OnPlayBGM();
        //OnOpenPanel(1);
    }

    public void OnInitListen()
    {
        EventCenter.AddListener<object>(EventType.On_OPEN_PANEL, OnOpenPanel);
    }

    public void OnOpenPanel(object type)
    {
        int type_ = (int)type;
        switch (type_)
        {
            case 1:loadingpanel.SetActive(true); break;
            case 2:lobbypanel.SetActive(true); break;
            case 3:mailpanel.SetActive(true); break;
            case 4:serverpanel.SetActive(true); break;
            case 5:settingpanel.SetActive(true); break;
            case 6:shoppanel.SetActive(true); break;
            case 7:gamepanel.SetActive(true); break;
        }
    }

    private void OnDestroy()
    {
        EventCenter.RemoveListener<object>(EventType.On_OPEN_PANEL, OnOpenPanel);
    }
}
